package cn.nexd.app.indoor.util;

import android.util.Log;

/**
 * Created by xun on 2016/3/24.
 */
public class LogUtil {

    public static final int VERBOSE = 2;
    public static final int DEBUG = 3;
    public static final int INFO = 4;
    public static final int WARN = 5;
    public static final int ERROR = 6;

    public static void printLog(String tag, String msg, int type) {
        if (type == VERBOSE) {
            Log.v(tag, msg);
        }
        if (type == DEBUG) {
            Log.d(tag, msg);
        }
        if (type == INFO) {
            Log.i(tag, msg);
        }
        if (type == WARN) {
            Log.w(tag, msg);
        }
        if (type == ERROR) {
            Log.e(tag, msg);
        }
    }
    private static String generateTag(StackTraceElement caller) {
        String tag = "%s.%s(L:%d)";
        String callerClazzName = caller.getClassName();
        callerClazzName = callerClazzName.substring(callerClazzName
                .lastIndexOf(".") + 1);
        tag = String.format(tag, callerClazzName, caller.getMethodName(),
                caller.getLineNumber());
        return tag;
    }

    public static StackTraceElement getCurrentStackTraceElement() {
        return Thread.currentThread().getStackTrace()[3];
    }

    public static StackTraceElement getCallerStackTraceElement() {
        return Thread.currentThread().getStackTrace()[4];
    }

}
